var a = getApp();

Page({
    data: {
        active: 2,
        info: {},
        listData: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.getdata(!0);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.page >= this.data.total_page) this.setData({
            isLoadMore: !1
        }); else if (this.data.isLoadMore) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    change: function(a) {
        this.setData({
            active: a.detail.name,
            page: 1,
            total_page: 0,
            listData: [],
            isLoadMore: !0
        }), this.getdata(!1);
    },
    getdata: function(t) {
        var e = this;
        wx.showLoading({
            title: "加载中"
        });
        var i = {};
        2 != this.data.active && (i.status = this.data.active);
        var o = a.getNetAddresss("plugin.commission-extra.frontend.index");
        a._postNetWork({
            url: o,
            data: i,
            success: function(a) {
                var i = a.data;
                if (wx.hideLoading(), 1 == i.result) {
                    if (t) {
                        wx.setNavigationBarTitle({
                            title: i.data.plugin_name
                        });
                        var o = {};
                        o.plugin_name = i.data.plugin_name, o.nickname = i.data.nickname, o.avatar = i.data.avatar, 
                        o.total_unsettle = i.data.total_unsettle, o.total_settle = i.data.total_settle, 
                        e.setData({
                            info: o
                        });
                    }
                    e.setData({
                        listData: i.data.data,
                        total_page: i.data.last_page
                    });
                } else wx.showToast({
                    title: i.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = {
            page: this.data.page,
            status: 2 == this.data.active ? null : this.data.active
        };
        this.data.isLoadMore = !1;
        var i = a.getNetAddresss("plugin.commission-extra.frontend.index");
        a._postNetWork({
            url: i,
            data: e,
            success: function(a) {
                var e = a.data;
                if (wx.hideLoading(), 1 == e.result) {
                    var i = e.data.data;
                    t.setData({
                        listData: t.data.listData.concat(i),
                        isLoadMore: !0
                    });
                } else {
                    var o = t.data.page - 1;
                    t.setData({
                        page: o,
                        isLoadMore: !0
                    }), wx.showToast({
                        title: e.msg,
                        duration: 1e3,
                        icon: "none"
                    });
                }
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});